package com.bosicloud.cmb.ibp.aws.adapter.component;


import com.alibaba.fastjson.JSONObject;
import com.bosicloud.cmb.ibp.QueueNames;
import com.bosicloud.cmb.ibp.aws.adapter.component.notify.NotifyServiceFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.aws.messaging.core.QueueMessagingTemplate;
import org.springframework.stereotype.Component;

/**
 * @author Jack Peng
 */
@Component
@Slf4j
public class NotifyExecutor {

    @Autowired
    QueueMessagingTemplate messagingTemplate;
    @Autowired
    QueueNames queueNames;

    public void receiveLogic(String payload) {

        log.debug(payload);

        JSONObject obj = JSONObject.parseObject(payload);
        String type = obj.getString("Type");
        NotifyServiceFactory.getService(type, payload, messagingTemplate, queueNames).exec();
    }

}
